package cn.hs.ph.dao.impl;

import cn.hs.ph.dao.UserDao;
import cn.hs.ph.util.JDBCDruidUtil;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoImpl implements UserDao {
    @Override
    public boolean login(String username, String pwd) {
        String sql = "SELECT * FROM USER;";
        Object obj[]={};
        ResultSet query = JDBCDruidUtil.query(sql,obj);
        while (true){
            try {
                if (!query.next()) break;
                String name = query.getString(2);
                String password = query.getString(3);
                if(username.equals(name) && pwd.equals(password)){
                    return true;
                }
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }

        }
        return false;
    }
}
